home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_48576.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  33 lines

  1. -- card: 48576 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 6
  9. ----- text -----
  10. 6.2  switch
  11.  
  12. -- part contents for background part 4
  13. ----- text -----
  14. The 'switch' statement accomplishes a multiway decision based on comparison of an expression with several alternative constant values.  The statements following each      'case' label are executed when the value of the tested expression matches the associated constant.  The 'default' label indicates the processing if no match is found.
  15.  
  16.     switch (i)
  17.     {
  18.         case  0:    result = 'a';
  19.                          break;
  20.         case 1:                                      /* "fall through" to processing for case 2 */
  21.         case 2:    result = 'b';
  22.                         break;
  23.         case 3:    result = 'c';
  24.                         break;
  25.         default:  result = 'd';
  26.                         break;
  27.     }
  28.  
  29.  
  30.  
  31. -- part contents for background part 7
  32. ----- text -----
  33. 159